import { ESHumanPoi, ESObjectWithLocation, ESSceneObject, ESUnrealActor } from "esobjs-xe2-plugin/dist-node/esobjs-xe2-plugin-main";
import { react, track, bind } from "xbsj-xe2/dist-node/xe2-base-utils";
export class ESHumanPoiActor extends ESObjectWithLocation {
    static type = this.register('ESHumanPoiActor', this, { chsName: '人员提示', tags: ['ESObjects'], description: "人员对象+提示对象" });
    get typeName() { return 'ESHumanPoiActor'; }
    get defaultProps() { return ESHumanPoiActor.createDefaultProps(); }
    get json() { return this._innerGetJson(); }
    set json(value) { this._innerSetJson(value); }

    private _actor = this.dv(ESSceneObject.createFromClass(ESUnrealActor))
    get actor() { return this._actor; }

    private _human = this.dv(new ESHumanPoi())
    get human() { return this._human; }


    // 模式
    private _mode = this.disposeVar(react('suitMan'));
    get mode() { return this._mode.value; }
    set mode(value) { this._mode.value = value }
    get modeChanged() { return this._mode.changed; }


    // 动画
    private _animation = this.disposeVar(react('standing'));
    get animation() { return this._animation.value; }
    set animation(value) { this._animation.value = value }
    get animationChanged() { return this._animation.changed; }

    // poi样式
    private _poiMode = this.disposeVar(react('ManNormal'));
    get poiMode() { return this._poiMode.value; }
    set poiMode(value) { this._poiMode.value = value }
    get poiModeChanged() { return this._poiMode.changed; }

    // 是否高亮
    private _highlight = this.disposeVar(react(false));
    get highlight() { return this._highlight.value; }
    set highlight(value) { this._highlight.value = value }
    get highlightChanged() { return this._highlight.changed; }



    aiMoveTo(Destination: [number, number, number], Time: number) {
        this.human.human.aiMoveTo(Destination, Time)
    }




    constructor(id?: string) {
        super(id);

        this.dispose(this.components.disposableAdd(this._human));
        this.d(track([this._human, 'show'], [this, 'show']));
        this.d(track([this._human, 'name'], [this, 'name']));
        this.d(bind([this._human, 'mode'], [this, 'mode']));
        this.d(bind([this._human, 'poiMode'], [this, 'poiMode']));
        this.d(bind([this._human, 'animation'], [this, 'animation']));
        this.d(bind([this._human, 'position'], [this, 'position']));
        this.d(bind([this._human, 'allowPicking'], [this, 'allowPicking']));
        this.d(this._human.pickedEvent.don(e => {
            this.pickedEvent.emit(e)
        }))


        this.dispose(this.components.disposableAdd(this._actor));
        this._actor.lastActorStatusChanged.don((e) => {
            if (e == 'created') {
                this._actor.allowPicking = false
                this._actor.collision = false
                this._actor.show = false
            }
        })
        this._actor.actorClass = "/Script/Engine.Blueprint'/Game/HSKJ/Blueprints/BP_LightRing.BP_LightRing'"


        this.d(bind([this._actor, 'position'], [this._human, 'position']));

        this.dispose(this.showChanged.don((val) => {
            if (!val) this._actor.show = val
        }))
        this.dispose(this.highlightChanged.don((val) => {
            if (this.show) this._actor.show = val
        }))

    }




}